package com.shuo.dsa.niuke;

import com.shuo.dsa.model.ListNode;

/**
 * 反转链表后，输出新链表的表头
 */
public class ReverseList {
    public ListNode ReverseList(ListNode head) {
        if (head == null) return null;
        ListNode pre = null;
        ListNode cur = head;
        while (cur != null) {
            ListNode next = cur.next;
            cur.next = pre;
            pre = cur;
            cur = next;
        }
        return pre;

    }
}
